document.addEventListener('DOMContentLoaded', () => {
    // 移动端菜单切换
    const mobileBtn = document.querySelector('.mobile-menu-btn');
    const navMenu = document.querySelector('.nav-menu');

    mobileBtn.addEventListener('click', () => {
        navMenu.style.display = navMenu.style.display === 'flex' ? 'none' : 'flex';
    });

    // 卡片交互效果
    document.querySelectorAll('.card').forEach(card => {
        card.addEventListener('mouseover', () => {
            card.style.boxShadow = '0 5px 15px rgba(0,0,0,0.2)';
        });
        
        card.addEventListener('mouseout', () => {
            card.style.boxShadow = '0 2px 5px rgba(0,0,0,0.1)';
        });
    });

    // 轮播图初始化（需配合第三方库使用）
    let currentIndex = 0;
    const carouselInner = document.querySelector('.carousel-inner');
    const items = document.querySelectorAll('.carousel-item');
    const totalItems = items.length;

    function showNextItem() {
        currentIndex = (currentIndex + 1) % totalItems; // 切换到下一张图片
        const offset = -currentIndex * 100; // 计算偏移量
        carouselInner.style.transform = `translateX(${offset}%)`; // 应用偏移
    }

    // 设置自动轮播，每隔3秒切换一次
    let carouselInterval = setInterval(showNextItem, 3000);

    // 可选：鼠标悬停时暂停轮播
    const carousel = document.querySelector('.carousel');
    carousel.addEventListener('mouseenter', () => {
        clearInterval(carouselInterval); // 暂停轮播
    });

    carousel.addEventListener('mouseleave', () => {
        carouselInterval = setInterval(showNextItem, 3000); // 恢复轮播
    });
    // 动态内容加载示例
    // fetch('data.json')
    //   .then(response => response.json())
    //   .then(data => renderContent(data));
});